class Setting < ActiveRecord::Base
  set_table_name :eshop_settings

  validates :preferred_company_name, :preferred_company_phone, :preferred_company_ico, :preferred_company_dic,
            :preferred_company_email, :presence => true

  validates :preferred_company_email, :format => {:with => Format::EMAIL_REGEX}
  validates :preferred_company_phone, :format => {:with => Format::PHONE_REGEX}

  #FrontEnd
    #Eshop company info
    preference :company_name, :string, :default => 'Allbox'
    preference :company_ico, :string
    preference :company_dic, :string
    preference :company_email, :string
    preference :company_phone, :string
    preference :company_address_street, :string
    preference :company_address_city, :string
    preference :company_address_zip, :string

  #BackEnd
    #Eshop photos
    preference :photo_watermark_path, :string, :default => "#{Rails.root}/app/assets/images/admin/watermark.png"
    preference :photo_small_watermark_path, :string, :default => "#{Rails.root}/app/assets/images/admin/small_watermark.png"
    preference :photo_watermark_position, :default => "center"

    preference :photo_small_thumb_size, :string, :default => "100x60"
    preference :photo_thumb_size, :string, :default => "200x120#"
    preference :photo_small_size, :string, :default => "300x240"
    preference :photo_large_size, :string, :default => "850x800>"

    preference :photo_thumb_watermark_position, :string, :default => "center"
    preference :photo_small_watermark_position, :string, :default => "center"
    preference :photo_large_watermark_position, :string, :default => "center"

    preference :photo_use_watermark, :boolean, :default => false
    
    def self.get(preference)
      Setting.first.preferred(preference)
    end
end
